import layoutHeaderAside from '@/layout/header-aside'

// 由于懒加载页面太多的话会造成webpack热更新太慢，所以开发环境不使用懒加载，只有生产环境使用懒加载
const _import = require('@/libs/util.import.' + process.env.NODE_ENV)

/**
 * 在主框架内显示
 */
const frameIn = [
  {
    path: '/dashboard',
    name: 'dashboard',
    meta: {
      title: '大屏',
      auth: true,
      hiddenInTab: true// 不显示在tab标签中
    },
    component: _import('dashboard/index')
  },
  {
    path: '/',
    redirect: { name: 'index' },
    component: layoutHeaderAside,
    children: [
      // 首页
      {
        path: 'index',
        name: 'index',
        meta: {
          title: '首页',
          auth: true
        },
        component: _import('system/index')
      },
      // 演示页面
      {
        path: 'page1',
        name: 'page1',
        meta: {
          title: '页面 1',
          auth: true
        },
        component: _import('demo/page1')
      },
      {
        path: 'page2',
        name: 'page2',
        meta: {
          title: '页面 2',
          auth: true
        },
        component: _import('demo/page2')
      },
      {
        path: 'page3',
        name: 'page3',
        meta: {
          title: '页面 3',
          auth: true
        },
        component: _import('demo/page3')
      },
      // 刷新页面 必须保留
      {
        path: 'refresh',
        name: 'refresh',
        hidden: true,
        component: _import('system/function/refresh')
      },
      // 页面重定向 必须保留
      {
        path: 'redirect/:route*',
        name: 'redirect',
        hidden: true,
        component: _import('system/function/redirect')
      }
    ]
  },
  {
    path: '/daily',
    component: layoutHeaderAside,
    redirect: { name: 'command' },
    children: [
      // {
      //   path: 'running',
      //   name: 'running',
      //   meta: {
      //     title: '运行管理',
      //     auth: true
      //   },
      //   component: _import('daily/running'),
      //   redirect: { name: 'command' },
      //   children: [
      //     {
      //       path: 'command',
      //       name: 'command',
      //       meta: {
      //         title: '设备指令',
      //         auth: true
      //       },
      //       component: _import('daily/running/command')
      //     }
      //   ]
      // },
      {
        path: 'fee',
        name: 'fee',
        meta: {
          title: '运营收费',
          auth: true
        },
        component: _import('daily/fee'),
        redirect: { name: 'customer' },
        children: [
          {
            path: 'chargeBill',
            name: 'chargeBill',
            meta: {
              title: '账单管理',
              auth: true
            },
            component: _import('daily/fee/chargeBill')
          },
          {
            path: 'customer',
            name: 'customer',
            meta: {
              title: '缴费管理',
              auth: true
            },
            component: _import('daily/fee/customer')
          },
          {
            path: 'query',
            name: 'query',
            meta: {
              title: '充值管理',
              auth: true
            },
            component: _import('daily/fee/query')
          },
          {
            path: 'arrearage',
            name: 'arrearage',
            meta: {
              title: '欠费查询',
              auth: true
            },
            component: _import('daily/fee/arrearage')
          },
          {
            path: 'refund',
            name: 'refund',
            meta: {
              title: '用户销户',
              auth: true
            },
            component: _import('daily/fee/refund')
          }
        ]
      },
      {
        path: 'client',
        name: 'client',
        meta: {
          title: '客户管理',
          auth: true
        },
        component: _import('daily/client'),
        redirect: { name: 'household' },
        children: [
          {
            path: 'household',
            name: 'household',
            meta: {
              title: '户号管理',
              auth: true
            },
            component: _import('daily/client/household')
          },
          {
            path: 'areaArchives',
            name: 'areaArchives',
            meta: {
              title: '档案管理',
              auth: true
            },
            component: _import('daily/client/areaArchives')
          }
        ]
      },

      {
        path: 'finance',
        name: 'finance',
        meta: {
          title: '财务管理',
          auth: true
        },
        component: _import('daily/finance'),
        redirect: { name: 'statistics' },
        children: [
          {
            path: 'statistics',
            name: 'statistics',
            meta: {
              title: '收费统计',
              auth: true
            },
            component: _import('daily/finance/statistics')
          },
          {
            path: 'customer1',
            name: 'customer1',
            meta: {
              title: '客户费用记录',
              auth: true
            },
            component: _import('daily/finance/customer1')
          },
          {
            path: 'bill',
            name: 'bill',
            meta: {
              title: '收费台账',
              auth: true
            },
            component: _import('daily/finance/bill')
          },
          // {
          //   path: 'check',
          //   name: 'check',
          //   meta: {
          //     title: '预付费核算',
          //     auth: true
          //   },
          //   component: _import('daily/finance/check')
          // },
          {
            path: 'fapiao',
            name: 'fapiao',
            meta: {
              title: '发票管理列表',
              auth: true
            },
            component: _import('daily/finance/fapiao')
          }
        ]
      },
      {
        path: 'device',
        name: 'device',
        meta: {
          title: '设备管理',
          auth: true
        },
        component: _import('daily/device'),
        redirect: { name: 'removewatch' },
        children: [
          {
            path: 'removewatch',
            name: 'removewatch',
            meta: {
              title: '拆换表',
              auth: true
            },
            component: _import('daily/device/removewatch')
          },
          {
            path: 'area',
            name: 'area',
            meta: {
              title: '区域管理',
              auth: true
            },
            component: _import('daily/device/area')
          },
          {
            path: 'concent',
            name: 'concent',
            meta: {
              title: '表具管理',
              auth: true
            },
            component: _import('daily/device/concent')
          },
          {
            path: 'remote',
            name: 'remote',
            meta: {
              title: '远程控制',
              auth: true
            },
            component: _import('daily/device/remote')
          }
        ]
      }
    ]
  },
  {

    path: '/statistics',
    component: layoutHeaderAside,
    children: [
      {
        path: 'analyze/tongbi',
        name: 'tongbi',
        meta: {
          title: '同比分析',
          auth: true
        },
        component: _import('statistics/analyze/tongbi')
      },
      {
        path: 'analyze/huanbi',
        name: 'huanbi',
        meta: {
          title: '环比分析统计',
          auth: true
        },
        component: _import('statistics/analyze/huanbi')
      },
      {
        path: 'analyze/trend',
        name: 'trend',
        meta: {
          title: '趋势分析',
          auth: true
        },
        component: _import('statistics/analyze/trend')
      },
      {
        path: 'analyze/userdosage',
        name: 'userdosage',
        meta: {
          title: '用户用量分析',
          auth: true
        },
        component: _import('statistics/analyze/userdosage')
      },
      {
        path: 'analyze/zerodosage',
        name: 'zerodosage',
        meta: {
          title: '零用量分析',
          auth: true
        },
        component: _import('statistics/analyze/zerodosage')
      },
      {
        path: 'analyze/junmpdosage',
        name: 'junmpdosage',
        meta: {
          title: '突增突减用量分析',
          auth: true
        },
        component: _import('statistics/analyze/junmpdosage')
      }
    ]
  },
  {
    path: '/admin',
    component: layoutHeaderAside,
    children: [
      {
        path: 'system/role',
        name: 'role',
        meta: {
          title: '角色管理',
          auth: true
        },
        component: _import('superManagement/role')
      },
      {
        path: 'system/user',
        name: 'user',
        meta: {
          title: '用户管理',
          auth: true
        },
        component: _import('superManagement/user')
      },
      {
        path: 'system/log',
        name: 'log',
        meta: {
          title: '系统日志',
          auth: true
        },
        component: _import('superManagement/log')
      },
      {
        path: 'params/supplier',
        name: 'supplier',
        meta: {
          title: '供应商管理',
          auth: true
        },
        component: _import('superManagement/params/supplier')
      },
      {
        path: 'params/charge',
        name: 'charge',
        meta: {
          title: '出账配置',
          auth: true
        },
        component: _import('superManagement/params/charge')
      },
      {
        path: 'params/equipmentmodel',
        name: 'equipmentmodel',
        meta: {
          title: '设备型号管理',
          auth: true
        },
        component: _import('superManagement/params/equipmentmodel')
      }, {
        path: 'params/instruction',
        name: 'instruction',
        meta: {
          title: '设备指令管理',
          auth: true
        },
        component: _import('superManagement/params/instruction')
      }, {
        path: 'params/price',
        name: 'price',
        meta: {
          title: '计费方案管理',
          auth: true
        },
        component: _import('superManagement/params/price')
      },
      // {
      //   path: 'params/metermodel',
      //   name: 'metermodel',
      //   meta: {
      //     title: '表计型号管理',
      //     auth: true
      //   },
      //   component: _import('superManagement/params/metermodel')
      // },
      {
        path: 'params/task',
        name: 'task',
        meta: {
          title: '定时任务配置',
          auth: true
        },
        component: _import('superManagement/params/task')
      }
    ]
  },
  {
    path: '/dataManagement',
    component: layoutHeaderAside,
    children: [
      // {
      //   path: 'meterReadingData/meterReadingRecord',
      //   name: 'meterReadingRecord',
      //   meta: {
      //     title: '抄表记录',
      //     auth: true
      //   },
      //   component: _import('dataManagement/meterReadingData/meterReadingRecord')
      // },
      {
        path: 'meterReadingData/bootstrapRecord',
        name: 'bootstrapRecord',
        meta: {
          title: '指令收发记录',
          auth: true
        },
        component: _import('dataManagement/meterReadingData/bootstrapRecord')
      },
      {
        path: 'meterReadingData/reportedData',
        name: 'reportedData',
        meta: {
          title: '表上报数据',
          auth: true
        },
        component: _import('dataManagement/meterReadingData/reportedData')
      }, {
        path: 'meterData/NBMeterStatus',
        name: 'NBMeterStatus',
        meta: {
          title: '表状态数据',
          auth: true
        },
        component: _import('dataManagement/meterData/NBMeterStatus')
      }, {
        path: 'meterData/NBMeterHistory',
        name: 'NBMeterHistory',
        meta: {
          title: '表历史数据',
          auth: true
        },
        component: _import('dataManagement/meterData/NBMeterHistory')
      },
      {
        path: 'meterData/NBMeterRealTime',
        name: 'NBMeterRealTime',
        meta: {
          title: '表实时数据',
          auth: true
        },
        component: _import('dataManagement/meterData/NBMeterRealTime')
      },
      {
        path: 'meterData/NBMeterFrozen',
        name: 'NBMeterFrozen',
        meta: {
          title: '表冻结数据',
          auth: true
        },
        component: _import('dataManagement/meterData/NBMeterFrozen')
      }
    ]
  }
]

/**
 * 在主框架之外显示
 */
const frameOut = [
  // 登录
  {
    path: '/login',
    name: 'login',
    component: _import('system/login')
  }
]

/**
 * 错误页面
 */
const errorPage = [
  {
    path: '*',
    name: '404',
    component: _import('system/error/404')
  }
]

// 导出需要显示菜单的
export const frameInRoutes = frameIn

// 重新组织后导出
export default [
  ...frameIn,
  ...frameOut,
  ...errorPage
]
